﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using KamLib.Web.MVC;


namespace KamLib.Web.Bootstrap
{


    partial class ButtonHelper
    {

        public static T Toggle<T>(this T me, string model, object trueValue = null, object falseValue = null)
            where T : Button
        {
            if (trueValue is string) trueValue = "'" + trueValue + "'";
            if (falseValue is string) falseValue = "'" + falseValue + "'";

            me.Attrs(
                @"ng-model=""" + model + @""" btn-checkbox" +
                (trueValue != null ? @" btn-checkbox-true=""" + trueValue + @"""" : null) +
                (falseValue != null ? @" btn-checkbox-false=""" + falseValue + @"""" : null)
            );
            return me;
        }


        public static T Radio<T>(this T me, string model, object value)
            where T : Button
        {
            if (value is string) value = "'" + value + "'";

            me.Attrs(
                @"ng-model=""" + model + @""" btn-radio=""" + value + @""""
            );
            return me;
        }

    }


    partial class UIBootstrapHelper
    {

        public override Button Handler(Button el, MvcElement dest = null)
        {
            (dest ?? el).Attrs(@"ng-click=""" + el.Title.Url + @"""");
            return el;
        }

    }


}
